<!DOCTYPE html><html><head>
      <title>RE</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///C:\Users\Python\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.4.3\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
      
      

      
      
      
      
      
      

      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <h1>&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;</h1>
<table>
<thead>
<tr>
<th>Tedu Python &#x6559;&#x5B66;&#x90E8;</th>
</tr>
</thead>
<tbody>
<tr>
<td>Author&#xFF1A;&#x5415;&#x6CFD;</td>
</tr>
</tbody>
</table>
<ul>
<li><a href="#%E5%8A%A8%E6%9C%BA">&#x52A8;&#x673A;</a></li>
<li><a href="#%E7%AE%80%E4%BB%8B">&#x7B80;&#x4ECB;</a></li>
<li><a href="#%E5%85%83%E5%AD%97%E7%AC%A6%E4%BD%BF%E7%94%A8">&#x5143;&#x5B57;&#x7B26;&#x4F7F;&#x7528;</a>
<ul>
<li><a href="#%E6%99%AE%E9%80%9A%E5%AD%97%E7%AC%A6">&#x666E;&#x901A;&#x5B57;&#x7B26;</a></li>
<li><a href="#%E6%88%96%E5%85%B3%E7%B3%BB">&#x6216;&#x5173;&#x7CFB;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E5%8D%95%E4%B8%AA%E5%AD%97%E7%AC%A6">&#x5339;&#x914D;&#x5355;&#x4E2A;&#x5B57;&#x7B26;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E9%9B%86">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x96C6;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E9%9B%86%E5%8F%8D%E9%9B%86">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x96C6;&#x53CD;&#x96C6;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%BC%80%E5%A7%8B%E4%BD%8D%E7%BD%AE">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x4E32;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9A%84%E7%BB%93%E6%9D%9F%E4%BD%8D%E7%BD%AE">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x7ED3;&#x675F;&#x4F4D;&#x7F6E;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E9%87%8D%E5%A4%8D">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x91CD;&#x590D;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E4%BB%BB%E6%84%8F%E9%9D%9E%E6%95%B0%E5%AD%97%E5%AD%97%E7%AC%A6">&#x5339;&#x914D;&#x4EFB;&#x610F;&#xFF08;&#x975E;&#xFF09;&#x6570;&#x5B57;&#x5B57;&#x7B26;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E4%BB%BB%E6%84%8F%E9%9D%9E%E6%99%AE%E9%80%9A%E5%AD%97%E7%AC%A6">&#x5339;&#x914D;&#x4EFB;&#x610F;&#xFF08;&#x975E;&#xFF09;&#x666E;&#x901A;&#x5B57;&#x7B26;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E4%BB%BB%E6%84%8F%E9%9D%9E%E7%A9%BA%E5%AD%97%E7%AC%A6">&#x5339;&#x914D;&#x4EFB;&#x610F;&#xFF08;&#x975E;&#xFF09;&#x7A7A;&#x5B57;&#x7B26;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E5%BC%80%E5%A4%B4%E7%BB%93%E5%B0%BE%E4%BD%8D%E7%BD%AE">&#x5339;&#x914D;&#x5F00;&#x5934;&#x7ED3;&#x5C3E;&#x4F4D;&#x7F6E;</a></li>
<li><a href="#%E5%8C%B9%E9%85%8D%E9%9D%9E%E5%8D%95%E8%AF%8D%E7%9A%84%E8%BE%B9%E7%95%8C%E4%BD%8D%E7%BD%AE">&#x5339;&#x914D;&#xFF08;&#x975E;&#xFF09;&#x5355;&#x8BCD;&#x7684;&#x8FB9;&#x754C;&#x4F4D;&#x7F6E;</a></li>
</ul>
</li>
<li><a href="#%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%9A%84%E8%BD%AC%E4%B9%89">&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x8F6C;&#x4E49;</a></li>
<li><a href="#%E8%B4%AA%E5%A9%AA%E6%A8%A1%E5%BC%8F%E5%92%8C%E9%9D%9E%E8%B4%AA%E5%A9%AA%E6%A8%A1%E5%BC%8F">&#x8D2A;&#x5A6A;&#x6A21;&#x5F0F;&#x548C;&#x975E;&#x8D2A;&#x5A6A;&#x6A21;&#x5F0F;</a></li>
<li><a href="#%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%88%86%E7%BB%84">&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5206;&#x7EC4;</a></li>
<li><a href="#%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%8C%B9%E9%85%8D%E5%8E%9F%E5%88%99">&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x539F;&#x5219;</a></li>
<li><a href="#python-re%E6%A8%A1%E5%9D%97%E4%BD%BF%E7%94%A8">Python re&#x6A21;&#x5757;&#x4F7F;&#x7528;</a>
<ul>
<li><a href="#match%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%B1%9E%E6%80%A7%E6%96%B9%E6%B3%95">match&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x65B9;&#x6CD5;</a></li>
<li><a href="#flags%E5%8F%82%E6%95%B0%E6%89%A9%E5%B1%95">flags&#x53C2;&#x6570;&#x6269;&#x5C55;</a></li>
</ul>
</li>
</ul>
<h2 class="mume-header" id="%E5%8A%A8%E6%9C%BA">&#x52A8;&#x673A;</h2>

<ol>
<li>
<p>&#x6587;&#x672C;&#x5904;&#x7406;&#x5DF2;&#x7ECF;&#x6210;&#x4E3A;&#x8BA1;&#x7B97;&#x673A;&#x5E38;&#x89C1;&#x5DE5;&#x4F5C;&#x4E4B;&#x4E00;</p>
</li>
<li>
<p>&#x5BF9;&#x6587;&#x672C;&#x5185;&#x5BB9;&#x7684;&#x641C;&#x7D22;&#xFF0C;&#x5B9A;&#x4F4D;&#xFF0C;&#x63D0;&#x53D6;&#x662F;&#x903B;&#x8F91;&#x6BD4;&#x8F83;&#x590D;&#x6742;&#x7684;&#x5DE5;&#x4F5C;</p>
</li>
<li>
<p>&#x4E3A;&#x4E86;&#x5FEB;&#x901F;&#x65B9;&#x4FBF;&#x7684;&#x89E3;&#x51B3;&#x4E0A;&#x8FF0;&#x95EE;&#x9898;&#xFF0C;&#x4EA7;&#x751F;&#x4E86;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x6280;&#x672F;</p>
</li>
</ol>
<h2 class="mume-header" id="%E7%AE%80%E4%BB%8B">&#x7B80;&#x4ECB;</h2>

<ol>
<li>&#x5B9A;&#x4E49;</li>
</ol>
<blockquote>
<p>&#x5373;&#x6587;&#x672C;&#x7684;&#x9AD8;&#x7EA7;&#x5339;&#x914D;&#x6A21;&#x5F0F;&#xFF0C;&#x63D0;&#x4F9B;&#x641C;&#x7D22;&#xFF0C;&#x66FF;&#x6362;&#x7B49;&#x529F;&#x80FD;&#x3002;&#x5176;&#x672C;&#x8D28;&#x662F;&#x7531;&#x4E00;&#x7CFB;&#x5217;&#x5B57;&#x7B26;&#x548C;&#x7279;&#x6B8A;&#x7B26;&#x53F7;&#x6784;&#x6210;&#x7684;&#x5B57;&#x4E32;&#xFF0C;&#x8FD9;&#x4E2A;&#x5B57;&#x4E32;&#x5373;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x3002;</p>
</blockquote>
<ol start="2">
<li>&#x539F;&#x7406;</li>
</ol>
<blockquote>
<p>&#x901A;&#x8FC7;&#x666E;&#x901A;&#x5B57;&#x7B26;&#x548C;&#x6709;&#x7279;&#x5B9A;&#x542B;&#x4E49;&#x7684;&#x5B57;&#x7B26;&#xFF0C;&#x6765;&#x7EC4;&#x6210;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x7528;&#x4EE5;&#x63CF;&#x8FF0;&#x4E00;&#x5B9A;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x89C4;&#x5219;&#xFF0C;&#x6BD4;&#x5982;&#xFF1A;&#x91CD;&#x590D;&#xFF0C;&#x4F4D;&#x7F6E;&#x7B49;&#xFF0C;&#x6765;&#x8868;&#x8FBE;&#x67D0;&#x7C7B;&#x7279;&#x5B9A;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x8FDB;&#x800C;&#x5339;&#x914D;&#x3002;</p>
</blockquote>
<ol start="3">
<li>&#x76EE;&#x6807;</li>
</ol>
<ul>
<li>
<p>&#x719F;&#x7EC3;&#x638C;&#x63E1;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5143;&#x5B57;&#x7B26;</p>
</li>
<li>
<p>&#x80FD;&#x591F;&#x8BFB;&#x61C2;&#x5E38;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x7F16;&#x8F91;&#x7B80;&#x5355;&#x7684;&#x6B63;&#x5219;&#x89C4;&#x5219;</p>
</li>
<li>
<p>&#x80FD;&#x591F;&#x719F;&#x7EC3;&#x4F7F;&#x7528;re&#x6A21;&#x5757;&#x64CD;&#x4F5C;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;</p>
</li>
</ul>
<h2 class="mume-header" id="%E5%85%83%E5%AD%97%E7%AC%A6%E4%BD%BF%E7%94%A8">&#x5143;&#x5B57;&#x7B26;&#x4F7F;&#x7528;</h2>

<h4 class="mume-header" id="%E6%99%AE%E9%80%9A%E5%AD%97%E7%AC%A6">&#x666E;&#x901A;&#x5B57;&#x7B26;</h4>

<ul>
<li>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A;&#x6BCF;&#x4E2A;&#x666E;&#x901A;&#x5B57;&#x7B26;&#x5339;&#x914D;&#x5176;&#x5BF9;&#x5E94;&#x7684;&#x5B57;&#x7B26;</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;ab&apos;,&quot;abcdefabcd&quot;)
Out: [&apos;ab&apos;, &apos;ab&apos;]
</code></pre><ul>
<li>&#x6CE8;&#x610F;&#x4E8B;&#x9879;&#xFF1A;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5728;python&#x4E2D;&#x4E5F;&#x53EF;&#x4EE5;&#x5339;&#x914D;&#x4E2D;&#x6587;</li>
</ul>
<h4 class="mume-header" id="%E6%88%96%E5%85%B3%E7%B3%BB">&#x6216;&#x5173;&#x7CFB;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;: |</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;: &#x5339;&#x914D; | &#x4E24;&#x4FA7;&#x4EFB;&#x610F;&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5373;&#x53EF;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;com|cn&apos;,&quot;www.baidu.com/www.tmooc.cn&quot;)
Out: [&apos;com&apos;, &apos;cn&apos;]

</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E5%8D%95%E4%B8%AA%E5%AD%97%E7%AC%A6">&#x5339;&#x914D;&#x5355;&#x4E2A;&#x5B57;&#x7B26;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A; .</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A;&#x5339;&#x914D;&#x9664;&#x6362;&#x884C;&#x5916;&#x7684;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;&#x5F20;.&#x4E30;&apos;,&quot;&#x5F20;&#x4E09;&#x4E30;,&#x5F20;&#x56DB;&#x4E30;,&#x5F20;&#x4E94;&#x4E30;&quot;)
Out: [&apos;&#x5F20;&#x4E09;&#x4E30;&apos;, &apos;&#x5F20;&#x56DB;&#x4E30;&apos;, &apos;&#x5F20;&#x4E94;&#x4E30;&apos;]

</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E9%9B%86">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x96C6;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A; [&#x5B57;&#x7B26;&#x96C6;]</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;: &#x5339;&#x914D;&#x5B57;&#x7B26;&#x96C6;&#x4E2D;&#x7684;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;</p>
</li>
<li>
<p>&#x8868;&#x8FBE;&#x5F62;&#x5F0F;:</p>
</li>
</ul>
<blockquote>
<blockquote>
<p>[abc#!&#x597D;] &#x8868;&#x793A; [] &#x4E2D;&#x7684;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;<br>
[0-9],[a-z],[A-Z] &#x8868;&#x793A;&#x533A;&#x95F4;&#x5185;&#x7684;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;<br>
[_#?0-9a-z]  &#x6DF7;&#x5408;&#x4E66;&#x5199;&#xFF0C;&#x4E00;&#x822C;&#x533A;&#x95F4;&#x8868;&#x8FBE;&#x5199;&#x5728;&#x540E;&#x9762;</p>
</blockquote>
</blockquote>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;[aeiou]&apos;,&quot;How are you!&quot;)
Out: [&apos;o&apos;, &apos;a&apos;, &apos;e&apos;, &apos;o&apos;, &apos;u&apos;]
</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E9%9B%86%E5%8F%8D%E9%9B%86">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x96C6;&#x53CD;&#x96C6;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A;[^&#x5B57;&#x7B26;&#x96C6;]</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A;&#x5339;&#x914D;&#x9664;&#x4E86;&#x5B57;&#x7B26;&#x96C6;&#x4EE5;&#x5916;&#x7684;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;[^0-9]&apos;,&quot;Use 007 port&quot;)
Out: [&apos;U&apos;, &apos;s&apos;, &apos;e&apos;, &apos; &apos;, &apos; &apos;, &apos;p&apos;, &apos;o&apos;, &apos;r&apos;, &apos;t&apos;]
</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%BC%80%E5%A7%8B%E4%BD%8D%E7%BD%AE">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x4E32;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;: ^</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A;&#x5339;&#x914D;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x5F00;&#x5934;&#x4F4D;&#x7F6E;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;^Jame&apos;,&quot;Jame,hello&quot;)
Out: [&apos;Jame&apos;]
</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9A%84%E7%BB%93%E6%9D%9F%E4%BD%8D%E7%BD%AE">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x7ED3;&#x675F;&#x4F4D;&#x7F6E;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;:  $</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;: &#x5339;&#x914D;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x7ED3;&#x5C3E;&#x4F4D;&#x7F6E;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;Jame$&apos;,&quot;Hi,Jame&quot;)
Out: [&apos;Jame&apos;]
</code></pre><ul>
<li>&#x89C4;&#x5219;&#x6280;&#x5DE7;: ^ &#x548C; $&#x5FC5;&#x7136;&#x51FA;&#x73B0;&#x5728;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5F00;&#x5934;&#x548C;&#x7ED3;&#x5C3E;&#x5904;&#x3002;&#x5982;&#x679C;&#x4E24;&#x8005;&#x540C;&#x65F6;&#x51FA;&#x73B0;&#xFF0C;&#x5219;&#x4E2D;&#x95F4;&#x7684;&#x90E8;&#x5206;&#x5FC5;&#x987B;&#x5339;&#x914D;&#x6574;&#x4E2A;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x5168;&#x90E8;&#x5185;&#x5BB9;&#x3002;</li>
</ul>
<h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E5%AD%97%E7%AC%A6%E9%87%8D%E5%A4%8D">&#x5339;&#x914D;&#x5B57;&#x7B26;&#x91CD;&#x590D;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;: *</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A;&#x5339;&#x914D;&#x524D;&#x9762;&#x7684;&#x5B57;&#x7B26;&#x51FA;&#x73B0;0&#x6B21;&#x6216;&#x591A;&#x6B21;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;wo*&apos;,&quot;wooooo~~w!&quot;)
Out: [&apos;wooooo&apos;, &apos;w&apos;]
</code></pre><hr>
<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A;+</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A; &#x5339;&#x914D;&#x524D;&#x9762;&#x7684;&#x5B57;&#x7B26;&#x51FA;&#x73B0;1&#x6B21;&#x6216;&#x591A;&#x6B21;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;[A-Z][a-z]+&apos;,&quot;Hello World&quot;)
Out: [&apos;Hello&apos;, &apos;World&apos;]
</code></pre><hr>
<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A;?</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A; &#x5339;&#x914D;&#x524D;&#x9762;&#x7684;&#x5B57;&#x7B26;&#x51FA;&#x73B0;0&#x6B21;&#x6216;1&#x6B21;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g. &#x5339;&#x914D;&#x6574;&#x6570;
In [28]: re.findall(&apos;-?[0-9]+&apos;,&quot;Jame,age:18, -26&quot;)
Out[28]: [&apos;18&apos;, &apos;-26&apos;]
</code></pre><hr>
<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A;{n}</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A; &#x5339;&#x914D;&#x524D;&#x9762;&#x7684;&#x5B57;&#x7B26;&#x51FA;&#x73B0;n&#x6B21;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g. &#x5339;&#x914D;&#x624B;&#x673A;&#x53F7;&#x7801;
In : re.findall(&apos;1[0-9]{10}&apos;,&quot;Jame:13886495728&quot;)
Out: [&apos;13886495728&apos;]

</code></pre><hr>
<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A;{m,n}</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A; &#x5339;&#x914D;&#x524D;&#x9762;&#x7684;&#x5B57;&#x7B26;&#x51FA;&#x73B0;m-n&#x6B21;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g. &#x5339;&#x914D;qq&#x53F7;
In : re.findall(&apos;[1-9][0-9]{5,10}&apos;,&quot;Baron:1259296994&quot;) 
Out: [&apos;1259296994&apos;]
</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E4%BB%BB%E6%84%8F%E9%9D%9E%E6%95%B0%E5%AD%97%E5%AD%97%E7%AC%A6">&#x5339;&#x914D;&#x4EFB;&#x610F;&#xFF08;&#x975E;&#xFF09;&#x6570;&#x5B57;&#x5B57;&#x7B26;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A; \d   \D</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A;\d &#x5339;&#x914D;&#x4EFB;&#x610F;&#x6570;&#x5B57;&#x5B57;&#x7B26;&#xFF0C;\D &#x5339;&#x914D;&#x4EFB;&#x610F;&#x975E;&#x6570;&#x5B57;&#x5B57;&#x7B26;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g. &#x5339;&#x914D;&#x7AEF;&#x53E3;
In : re.findall(&apos;\d{1,5}&apos;,&quot;Mysql: 3306, http:80&quot;)
Out: [&apos;3306&apos;, &apos;80&apos;]
</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E4%BB%BB%E6%84%8F%E9%9D%9E%E6%99%AE%E9%80%9A%E5%AD%97%E7%AC%A6">&#x5339;&#x914D;&#x4EFB;&#x610F;&#xFF08;&#x975E;&#xFF09;&#x666E;&#x901A;&#x5B57;&#x7B26;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A; \w   \W</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;: \w &#x5339;&#x914D;&#x666E;&#x901A;&#x5B57;&#x7B26;&#xFF0C;\W &#x5339;&#x914D;&#x975E;&#x666E;&#x901A;&#x5B57;&#x7B26;</p>
</li>
<li>
<p>&#x8BF4;&#x660E;: &#x666E;&#x901A;&#x5B57;&#x7B26;&#x6307;&#x6570;&#x5B57;&#xFF0C;&#x5B57;&#x6BCD;&#xFF0C;&#x4E0B;&#x5212;&#x7EBF;&#xFF0C;&#x6C49;&#x5B57;&#x3002;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;\w+&apos;,&quot;server_port = 8888&quot;)
Out: [&apos;server_port&apos;, &apos;8888&apos;]
</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E4%BB%BB%E6%84%8F%E9%9D%9E%E7%A9%BA%E5%AD%97%E7%AC%A6">&#x5339;&#x914D;&#x4EFB;&#x610F;&#xFF08;&#x975E;&#xFF09;&#x7A7A;&#x5B57;&#x7B26;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A; \s   \S</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;: \s &#x5339;&#x914D;&#x7A7A;&#x5B57;&#x7B26;&#xFF0C;\S &#x5339;&#x914D;&#x975E;&#x7A7A;&#x5B57;&#x7B26;</p>
</li>
<li>
<p>&#x8BF4;&#x660E;&#xFF1A;&#x7A7A;&#x5B57;&#x7B26;&#x6307; &#x7A7A;&#x683C; \r \n \t \v \f &#x5B57;&#x7B26;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(&apos;\w+\s+\w+&apos;,&quot;hello    world&quot;)
Out: [&apos;hello    world&apos;]
</code></pre><h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E5%BC%80%E5%A4%B4%E7%BB%93%E5%B0%BE%E4%BD%8D%E7%BD%AE">&#x5339;&#x914D;&#x5F00;&#x5934;&#x7ED3;&#x5C3E;&#x4F4D;&#x7F6E;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A; \A   \Z</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A; \A &#x8868;&#x793A;&#x5F00;&#x5934;&#x4F4D;&#x7F6E;&#xFF0C;\Z &#x8868;&#x793A;&#x7ED3;&#x5C3E;&#x4F4D;&#x7F6E;</p>
</li>
</ul>
<h4 class="mume-header" id="%E5%8C%B9%E9%85%8D%E9%9D%9E%E5%8D%95%E8%AF%8D%E7%9A%84%E8%BE%B9%E7%95%8C%E4%BD%8D%E7%BD%AE">&#x5339;&#x914D;&#xFF08;&#x975E;&#xFF09;&#x5355;&#x8BCD;&#x7684;&#x8FB9;&#x754C;&#x4F4D;&#x7F6E;</h4>

<ul>
<li>
<p>&#x5143;&#x5B57;&#x7B26;&#xFF1A; \b   \B</p>
</li>
<li>
<p>&#x5339;&#x914D;&#x89C4;&#x5219;&#xFF1A; \b &#x8868;&#x793A;&#x5355;&#x8BCD;&#x8FB9;&#x754C;&#xFF0C;\B &#x8868;&#x793A;&#x975E;&#x5355;&#x8BCD;&#x8FB9;&#x754C;</p>
</li>
<li>
<p>&#x8BF4;&#x660E;&#xFF1A;&#x5355;&#x8BCD;&#x8FB9;&#x754C;&#x6307;&#x6570;&#x5B57;&#x5B57;&#x6BCD;(&#x6C49;&#x5B57;)&#x4E0B;&#x5212;&#x7EBF;&#x4E0E;&#x5176;&#x4ED6;&#x5B57;&#x7B26;&#x7684;&#x4EA4;&#x754C;&#x4F4D;&#x7F6E;&#x3002;</p>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(r&apos;\bis\b&apos;,&quot;This is a test.&quot;)
Out: [&apos;is&apos;]
</code></pre><table>
<thead>
<tr>
<th>&#x7C7B;&#x522B;</th>
<th>&#x5143;&#x5B57;&#x7B26;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x5339;&#x914D;&#x5B57;&#x7B26;</td>
<td>. [...] [^...] \d \D \w \W \s \S</td>
</tr>
<tr>
<td>&#x5339;&#x914D;&#x91CD;&#x590D;</td>
<td>* +  ?  {n}  {m,n}</td>
</tr>
<tr>
<td>&#x5339;&#x914D;&#x4F4D;&#x7F6E;</td>
<td>^  $  \A  \Z  \b   \B</td>
</tr>
<tr>
<td>&#x5176;&#x4ED6;</td>
<td><code>|</code>   ()    \</td>
</tr>
</tbody>
</table>
<h2 class="mume-header" id="%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%9A%84%E8%BD%AC%E4%B9%89">&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x8F6C;&#x4E49;</h2>

<ol>
<li>&#x5982;&#x679C;&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x7279;&#x6B8A;&#x5B57;&#x7B26;&#x5219;&#x9700;&#x8981;&#x52A0; \ &#x8868;&#x793A;&#x8F6C;&#x4E49;&#x3002;</li>
</ol>
<blockquote>
<blockquote>
<p>&#x7279;&#x6B8A;&#x5B57;&#x7B26;: . * + ? ^ $ [] () {} | \</p>
</blockquote>
</blockquote>
<pre data-role="codeBlock" data-info class="language-"><code>e.g. &#x5339;&#x914D;&#x7279;&#x6B8A;&#x5B57;&#x7B26; . &#x65F6;&#x4F7F;&#x7528; \. &#x8868;&#x793A;&#x672C;&#x8EAB;&#x542B;&#x4E49;
In : re.findall(&apos;-?\d+\.?\d*&apos;,&quot;123,-123,1.23,-1.23&quot;)
Out: [&apos;123&apos;, &apos;-123&apos;, &apos;1.23&apos;, &apos;-1.23&apos;]
</code></pre><ol start="2">
<li>&#x5728;&#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#x4E2D;&#xFF0C;&#x5E38;&#x4F7F;&#x7528;&#x539F;&#x751F;&#x5B57;&#x7B26;&#x4E32;&#x4E66;&#x5199;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x907F;&#x514D;&#x591A;&#x91CD;&#x8F6C;&#x4E49;&#x7684;&#x9EBB;&#x70E6;&#x3002;</li>
</ol>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.
python&#x5B57;&#x7B26;&#x4E32;  --&gt;    &#x6B63;&#x5219;    --&gt;    &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
&quot;\\$\\d+&quot;   &#x89E3;&#x6790;&#x4E3A;   \$\d+   &#x5339;&#x914D;   &quot;$100&quot;

&quot;\\$\\d+&quot;  &#x7B49;&#x540C;&#x4E8E;  r&quot;\$\d+&quot;
</code></pre><h2 class="mume-header" id="%E8%B4%AA%E5%A9%AA%E6%A8%A1%E5%BC%8F%E5%92%8C%E9%9D%9E%E8%B4%AA%E5%A9%AA%E6%A8%A1%E5%BC%8F">&#x8D2A;&#x5A6A;&#x6A21;&#x5F0F;&#x548C;&#x975E;&#x8D2A;&#x5A6A;&#x6A21;&#x5F0F;</h2>

<ol>
<li>&#x5B9A;&#x4E49;</li>
</ol>
<blockquote>
<p>&#x8D2A;&#x5A6A;&#x6A21;&#x5F0F;: &#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5339;&#x914D;&#x91CD;&#x590D;&#x7684;&#x5143;&#x5B57;&#x7B26;&#x603B;&#x662F;&#x5C3D;&#x53EF;&#x80FD;&#x591A;&#x7684;&#x5411;&#x540E;&#x5339;&#x914D;&#x5185;&#x5BB9;&#x3002;&#x6BD4;&#x5982;: *  +  ?  {m,n}</p>
</blockquote>
<blockquote>
<p>&#x975E;&#x8D2A;&#x5A6A;&#x6A21;&#x5F0F;(&#x61D2;&#x60F0;&#x6A21;&#x5F0F;): &#x8BA9;&#x5339;&#x914D;&#x91CD;&#x590D;&#x7684;&#x5143;&#x5B57;&#x7B26;&#x5C3D;&#x53EF;&#x80FD;&#x5C11;&#x7684;&#x5411;&#x540E;&#x5339;&#x914D;&#x5185;&#x5BB9;&#x3002;</p>
</blockquote>
<ol start="2">
<li>&#x8D2A;&#x5A6A;&#x6A21;&#x5F0F;&#x8F6C;&#x6362;&#x4E3A;&#x975E;&#x8D2A;&#x5A6A;&#x6A21;&#x5F0F;</li>
</ol>
<ul>
<li>&#x5728;&#x5339;&#x914D;&#x91CD;&#x590D;&#x5143;&#x5B57;&#x7B26;&#x540E;&#x52A0; &apos;?&apos; &#x53F7;&#x5373;&#x53EF;</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>*  :  *?
+  :  +?
?  :  ??
{m,n} : {m,n}?
</code></pre><pre data-role="codeBlock" data-info class="language-"><code>e.g.
In : re.findall(r&apos;\(.+?\)&apos;,&quot;(abcd)efgh(higk)&quot;)
Out: [&apos;(abcd)&apos;, &apos;(higk)&apos;]
</code></pre><h2 class="mume-header" id="%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%88%86%E7%BB%84">&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5206;&#x7EC4;</h2>

<ol>
<li>&#x5B9A;&#x4E49;</li>
</ol>
<blockquote>
<p>&#x5728;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#xFF0C;&#x4EE5;()&#x5EFA;&#x7ACB;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5185;&#x90E8;&#x5206;&#x7EC4;&#xFF0C;&#x5B50;&#x7EC4;&#x662F;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x53EF;&#x4EE5;&#x4F5C;&#x4E3A;&#x5185;&#x90E8;&#x6574;&#x4F53;&#x64CD;&#x4F5C;&#x5BF9;&#x8C61;&#x3002;</p>
</blockquote>
<ol start="2">
<li>&#x4F5C;&#x7528;</li>
</ol>
<ul>
<li>&#x53EF;&#x4EE5;&#x88AB;&#x4F5C;&#x4E3A;&#x6574;&#x4F53;&#x64CD;&#x4F5C;&#xFF0C;&#x6539;&#x53D8;&#x5143;&#x5B57;&#x7B26;&#x7684;&#x64CD;&#x4F5C;&#x5BF9;&#x8C61;</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g.  &#x6539;&#x53D8; +&#x53F7; &#x91CD;&#x590D;&#x7684;&#x5BF9;&#x8C61;
In : re.search(r&apos;(ab)+&apos;,&quot;ababababab&quot;).group()
Out: &apos;ababababab&apos;

e.g. &#x6539;&#x53D8; |&#x53F7; &#x64CD;&#x4F5C;&#x5BF9;&#x8C61;
In : re.search(r&apos;(&#x738B;|&#x674E;)\w{1,3}&apos;,&quot;&#x738B;&#x8005;&#x8363;&#x8000;&quot;).group()
Out: &apos;&#x738B;&#x8005;&#x8363;&#x8000;&apos;
</code></pre><ul>
<li>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#x67D0;&#x4E9B;&#x63A5;&#x53E3;&#x83B7;&#x53D6;&#x5339;&#x914D;&#x5185;&#x5BB9;&#x4E2D;&#xFF0C;&#x5B50;&#x7EC4;&#x5BF9;&#x5E94;&#x7684;&#x5185;&#x5BB9;&#x90E8;&#x5206;</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>e.g. &#x83B7;&#x53D6;url&#x534F;&#x8BAE;&#x7C7B;&#x578B;
re.search(r&apos;(https|http|ftp|file)://\S+&apos;,&quot;https://www.baidu.com&quot;).group(1)

</code></pre><ol start="3">
<li>&#x6355;&#x83B7;&#x7EC4;</li>
</ol>
<p>&#x53EF;&#x4EE5;&#x7ED9;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5B50;&#x7EC4;&#x8D77;&#x4E00;&#x4E2A;&#x540D;&#x5B57;&#xFF0C;&#x8868;&#x8FBE;&#x8BE5;&#x5B50;&#x7EC4;&#x7684;&#x610F;&#x4E49;&#x3002;&#x8FD9;&#x79CD;&#x6709;&#x540D;&#x79F0;&#x7684;&#x5B50;&#x7EC4;&#x5373;&#x4E3A;&#x6355;&#x83B7;&#x7EC4;&#x3002;</p>
<blockquote>
<p>&#x683C;&#x5F0F;&#xFF1A;<code>(?P&lt;name&gt;pattern)</code></p>
</blockquote>
<pre data-role="codeBlock" data-info class="language-"><code>e.g. &#x7ED9;&#x5B50;&#x7EC4;&#x547D;&#x540D;&#x4E3A; &quot;pig&quot;
In : re.search(r&apos;(?P&lt;pig&gt;ab)+&apos;,&quot;ababababab&quot;).group(&apos;pig&apos;)
Out: &apos;ab&apos;

</code></pre><ol start="4">
<li>&#x6CE8;&#x610F;&#x4E8B;&#x9879;</li>
</ol>
<ul>
<li>&#x4E00;&#x4E2A;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x591A;&#x4E2A;&#x5B50;&#x7EC4;</li>
<li>&#x5B50;&#x7EC4;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x8981;&#x91CD;&#x53E0;&#x6216;&#x8005;&#x5D4C;&#x5957;&#x7ED3;&#x6784;&#x590D;&#x6742;</li>
<li>&#x5B50;&#x7EC4;&#x5E8F;&#x5217;&#x53F7;&#x4E00;&#x822C;&#x4ECE;&#x5916;&#x5230;&#x5185;&#xFF0C;&#x4ECE;&#x5DE6;&#x5230;&#x53F3;&#x8BA1;&#x6570;</li>
</ul>
<p><img src="img/re.png" alt="&#x5206;&#x7EC4;"></p>
<h2 class="mume-header" id="%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%8C%B9%E9%85%8D%E5%8E%9F%E5%88%99">&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x539F;&#x5219;</h2>

<ol>
<li>&#x6B63;&#x786E;&#x6027;,&#x80FD;&#x591F;&#x6B63;&#x786E;&#x7684;&#x5339;&#x914D;&#x51FA;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;.</li>
<li>&#x6392;&#x4ED6;&#x6027;,&#x9664;&#x4E86;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x4E4B;&#x5916;&#x5C3D;&#x53EF;&#x80FD;&#x5C11;&#x7684;&#x5339;&#x914D;&#x5176;&#x4ED6;&#x5185;&#x5BB9;.</li>
<li>&#x5168;&#x9762;&#x6027;,&#x5C3D;&#x53EF;&#x80FD;&#x8003;&#x8651;&#x5230;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x6240;&#x6709;&#x60C5;&#x51B5;,&#x4E0D;&#x9057;&#x6F0F;.</li>
</ol>
<h2 class="mume-header" id="python-re%E6%A8%A1%E5%9D%97%E4%BD%BF%E7%94%A8">Python re&#x6A21;&#x5757;&#x4F7F;&#x7528;</h2>

<p><em><strong>&#x53C2;&#x8003;&#x4EE3;&#x7801;day13/regex.py</strong></em></p>
<hr>
<pre data-role="codeBlock" data-info="python" class="language-python"> regex <span class="token operator">=</span> <span class="token builtin">compile</span><span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>flags <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
 &#x529F;&#x80FD;<span class="token punctuation">:</span> &#x751F;&#x4EA7;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5BF9;&#x8C61;
 &#x53C2;&#x6570;<span class="token punctuation">:</span> pattern  &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;
      flags  &#x529F;&#x80FD;&#x6807;&#x5FD7;&#x4F4D;<span class="token punctuation">,</span>&#x6269;&#x5C55;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5339;&#x914D;
 &#x8FD4;&#x56DE;&#x503C;<span class="token punctuation">:</span> &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5BF9;&#x8C61;
</pre><hr>
<pre data-role="codeBlock" data-info="python" class="language-python"> re<span class="token punctuation">.</span>findall<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>string<span class="token punctuation">,</span>flags <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
 &#x529F;&#x80FD;<span class="token punctuation">:</span> &#x6839;&#x636E;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x5185;&#x5BB9;
 &#x53C2;&#x6570;<span class="token punctuation">:</span> pattern  &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;
      string &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
      flags  &#x529F;&#x80FD;&#x6807;&#x5FD7;&#x4F4D;<span class="token punctuation">,</span>&#x6269;&#x5C55;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5339;&#x914D;
 &#x8FD4;&#x56DE;&#x503C;<span class="token punctuation">:</span> &#x5339;&#x914D;&#x5230;&#x7684;&#x5185;&#x5BB9;&#x5217;&#x8868;<span class="token punctuation">,</span>&#x5982;&#x679C;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x6709;&#x5B50;&#x7EC4;&#x5219;&#x53EA;&#x80FD;&#x83B7;&#x53D6;&#x5230;&#x5B50;&#x7EC4;&#x5BF9;&#x5E94;&#x7684;&#x5185;&#x5BB9;
</pre><hr>
<pre data-role="codeBlock" data-info="python" class="language-python"> regex<span class="token punctuation">.</span>findall<span class="token punctuation">(</span>string<span class="token punctuation">,</span>pos<span class="token punctuation">,</span>endpos<span class="token punctuation">)</span>
 &#x529F;&#x80FD;<span class="token punctuation">:</span> &#x6839;&#x636E;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x5185;&#x5BB9;
 &#x53C2;&#x6570;<span class="token punctuation">:</span> string &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
      pos &#x622A;&#x53D6;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x5F00;&#x59CB;&#x5339;&#x914D;&#x4F4D;&#x7F6E;
      endpos &#x622A;&#x53D6;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x7ED3;&#x675F;&#x5339;&#x914D;&#x4F4D;&#x7F6E;
 &#x8FD4;&#x56DE;&#x503C;<span class="token punctuation">:</span> &#x5339;&#x914D;&#x5230;&#x7684;&#x5185;&#x5BB9;&#x5217;&#x8868;<span class="token punctuation">,</span>&#x5982;&#x679C;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x6709;&#x5B50;&#x7EC4;&#x5219;&#x53EA;&#x80FD;&#x83B7;&#x53D6;&#x5230;&#x5B50;&#x7EC4;&#x5BF9;&#x5E94;&#x7684;&#x5185;&#x5BB9;
</pre><hr>
<pre data-role="codeBlock" data-info="python" class="language-python">re<span class="token punctuation">.</span>split<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>string<span class="token punctuation">,</span>flags <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
&#x529F;&#x80FD;<span class="token punctuation">:</span> &#x4F7F;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x5185;&#x5BB9;<span class="token punctuation">,</span>&#x5207;&#x5272;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
&#x53C2;&#x6570;<span class="token punctuation">:</span> pattern  &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;
     string &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
     flags  &#x529F;&#x80FD;&#x6807;&#x5FD7;&#x4F4D;<span class="token punctuation">,</span>&#x6269;&#x5C55;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5339;&#x914D;
&#x8FD4;&#x56DE;&#x503C;<span class="token punctuation">:</span> &#x5207;&#x5272;&#x540E;&#x7684;&#x5185;&#x5BB9;&#x5217;&#x8868;
</pre><hr>
<pre data-role="codeBlock" data-info="python" class="language-python"> re<span class="token punctuation">.</span>sub<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>replace<span class="token punctuation">,</span>string<span class="token punctuation">,</span><span class="token builtin">max</span><span class="token punctuation">,</span>flags <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
 &#x529F;&#x80FD;<span class="token punctuation">:</span> &#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x66FF;&#x6362;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x5230;&#x7684;&#x5185;&#x5BB9;
 &#x53C2;&#x6570;<span class="token punctuation">:</span> pattern  &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;
      replace  &#x66FF;&#x6362;&#x7684;&#x5B57;&#x7B26;&#x4E32;
      string &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
      <span class="token builtin">max</span>  &#x6700;&#x591A;&#x66FF;&#x6362;&#x51E0;&#x5904;<span class="token punctuation">,</span>&#x9ED8;&#x8BA4;&#x66FF;&#x6362;&#x5168;&#x90E8;
      flags  &#x529F;&#x80FD;&#x6807;&#x5FD7;&#x4F4D;<span class="token punctuation">,</span>&#x6269;&#x5C55;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5339;&#x914D;
 &#x8FD4;&#x56DE;&#x503C;<span class="token punctuation">:</span> &#x66FF;&#x6362;&#x540E;&#x7684;&#x5B57;&#x7B26;&#x4E32;
</pre><hr>
<pre data-role="codeBlock" data-info="python" class="language-python"> re<span class="token punctuation">.</span>subn<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>replace<span class="token punctuation">,</span>string<span class="token punctuation">,</span><span class="token builtin">max</span><span class="token punctuation">,</span>flags <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
 &#x529F;&#x80FD;<span class="token punctuation">:</span> &#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x66FF;&#x6362;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x5230;&#x7684;&#x5185;&#x5BB9;
 &#x53C2;&#x6570;<span class="token punctuation">:</span> pattern  &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;
      replace  &#x66FF;&#x6362;&#x7684;&#x5B57;&#x7B26;&#x4E32;
      string &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
      <span class="token builtin">max</span>  &#x6700;&#x591A;&#x66FF;&#x6362;&#x51E0;&#x5904;<span class="token punctuation">,</span>&#x9ED8;&#x8BA4;&#x66FF;&#x6362;&#x5168;&#x90E8;
      flags  &#x529F;&#x80FD;&#x6807;&#x5FD7;&#x4F4D;<span class="token punctuation">,</span>&#x6269;&#x5C55;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5339;&#x914D;
 &#x8FD4;&#x56DE;&#x503C;<span class="token punctuation">:</span> &#x66FF;&#x6362;&#x540E;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x548C;&#x66FF;&#x6362;&#x4E86;&#x51E0;&#x5904;
</pre><hr>
<p><em><strong>&#x53C2;&#x8003;&#x4EE3;&#x7801;day13/regex1.py</strong></em></p>
<pre data-role="codeBlock" data-info="python" class="language-python"> re<span class="token punctuation">.</span>finditer<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>string<span class="token punctuation">,</span>flags <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
 &#x529F;&#x80FD;<span class="token punctuation">:</span> &#x6839;&#x636E;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5339;&#x914D;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x5185;&#x5BB9;
 &#x53C2;&#x6570;<span class="token punctuation">:</span> pattern  &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;
      string &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
      flags  &#x529F;&#x80FD;&#x6807;&#x5FD7;&#x4F4D;<span class="token punctuation">,</span>&#x6269;&#x5C55;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5339;&#x914D;
 &#x8FD4;&#x56DE;&#x503C;<span class="token punctuation">:</span> &#x5339;&#x914D;&#x7ED3;&#x679C;&#x7684;&#x8FED;&#x4EE3;&#x5668;
</pre><hr>
<pre data-role="codeBlock" data-info="python" class="language-python">re<span class="token punctuation">.</span>fullmatch<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>string<span class="token punctuation">,</span>flags<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">)</span>
&#x529F;&#x80FD;&#xFF1A;&#x5B8C;&#x5168;&#x5339;&#x914D;&#x67D0;&#x4E2A;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
&#x53C2;&#x6570;&#xFF1A;pattern &#x6B63;&#x5219;
	string  &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x5339;&#x914D;&#x5185;&#x5BB9;match <span class="token builtin">object</span>
</pre><hr>
<pre data-role="codeBlock" data-info="python" class="language-python">re<span class="token punctuation">.</span>match<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>string<span class="token punctuation">,</span>flags<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">)</span>
&#x529F;&#x80FD;&#xFF1A;&#x5339;&#x914D;&#x67D0;&#x4E2A;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;
&#x53C2;&#x6570;&#xFF1A;pattern &#x6B63;&#x5219;
	string  &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x5339;&#x914D;&#x5185;&#x5BB9;match <span class="token builtin">object</span>
</pre><hr>
<pre data-role="codeBlock" data-info="python" class="language-python">re<span class="token punctuation">.</span>search<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span>string<span class="token punctuation">,</span>flags<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">)</span>
&#x529F;&#x80FD;&#xFF1A;&#x5339;&#x914D;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7B2C;&#x4E00;&#x4E2A;&#x7B26;&#x5408;&#x5185;&#x5BB9;
&#x53C2;&#x6570;&#xFF1A;pattern &#x6B63;&#x5219;
	string  &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;
&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x5339;&#x914D;&#x5185;&#x5BB9;match <span class="token builtin">object</span>
</pre><hr>
<p>compile&#x5BF9;&#x8C61;&#x5C5E;&#x6027;</p>
<pre class="language-text">&#x3010;1&#x3011; pattern &#xFF1A; &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;
&#x3010;2&#x3011; groups &#xFF1A; &#x5B50;&#x7EC4;&#x6570;&#x91CF;
&#x3010;3&#x3011; groupindex &#xFF1A; &#x6355;&#x83B7;&#x7EC4;&#x540D;&#x4E0E;&#x7EC4;&#x5E8F;&#x53F7;&#x7684;&#x5B57;&#x5178;
</pre>
<hr>
<h3 class="mume-header" id="match%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%B1%9E%E6%80%A7%E6%96%B9%E6%B3%95">match&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x65B9;&#x6CD5;</h3>

<p><em><strong>&#x53C2;&#x8003;&#x4EE3;&#x7801;day13/regex2.py</strong></em></p>
<ol>
<li>&#x5C5E;&#x6027;&#x53D8;&#x91CF;</li>
</ol>
<ul>
<li>pos   &#x5339;&#x914D;&#x7684;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;</li>
<li>endpos  &#x5339;&#x914D;&#x7684;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7ED3;&#x675F;&#x4F4D;&#x7F6E;</li>
<li>re     &#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;</li>
<li>string  &#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;</li>
<li>lastgroup  &#x6700;&#x540E;&#x4E00;&#x7EC4;&#x7684;&#x540D;&#x79F0;</li>
<li>lastindex  &#x6700;&#x540E;&#x4E00;&#x7EC4;&#x7684;&#x5E8F;&#x53F7;</li>
</ul>
<ol start="2">
<li>&#x5C5E;&#x6027;&#x65B9;&#x6CD5;</li>
</ol>
<ul>
<li>
<p>span()  &#x83B7;&#x53D6;&#x5339;&#x914D;&#x5185;&#x5BB9;&#x7684;&#x8D77;&#x6B62;&#x4F4D;&#x7F6E;</p>
</li>
<li>
<p>start() &#x83B7;&#x53D6;&#x5339;&#x914D;&#x5185;&#x5BB9;&#x7684;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;</p>
</li>
<li>
<p>end()   &#x83B7;&#x53D6;&#x5339;&#x914D;&#x5185;&#x5BB9;&#x7684;&#x7ED3;&#x675F;&#x4F4D;&#x7F6E;</p>
</li>
<li>
<p>groupdict()  &#x83B7;&#x53D6;&#x6355;&#x83B7;&#x7EC4;&#x5B57;&#x5178;&#xFF0C;&#x7EC4;&#x540D;&#x4E3A;&#x952E;&#xFF0C;&#x5BF9;&#x5E94;&#x5185;&#x5BB9;&#x4E3A;&#x503C;</p>
</li>
<li>
<p>groups() &#x83B7;&#x53D6;&#x5B50;&#x7EC4;&#x5BF9;&#x5E94;&#x5185;&#x5BB9;</p>
</li>
<li>
<p>group(n = 0)</p>
<pre class="language-text">&#x529F;&#x80FD;&#xFF1A;&#x83B7;&#x53D6;match&#x5BF9;&#x8C61;&#x5339;&#x914D;&#x5185;&#x5BB9;
&#x53C2;&#x6570;&#xFF1A;&#x9ED8;&#x8BA4;&#x4E3A;0&#x8868;&#x793A;&#x83B7;&#x53D6;&#x6574;&#x4E2A;match&#x5BF9;&#x8C61;&#x5185;&#x5BB9;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x5E8F;&#x5217;&#x53F7;&#x6216;&#x8005;&#x7EC4;&#x540D;&#x5219;&#x8868;&#x793A;&#x83B7;&#x53D6;&#x5BF9;&#x5E94;&#x5B50;&#x7EC4;&#x5185;&#x5BB9;
&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x5339;&#x914D;&#x5B57;&#x7B26;&#x4E32;
</pre>
</li>
</ul>
<p><img src="img/re1.png" alt="&#x7ED3;&#x6784;"></p>
<h3 class="mume-header" id="flags%E5%8F%82%E6%95%B0%E6%89%A9%E5%B1%95">flags&#x53C2;&#x6570;&#x6269;&#x5C55;</h3>

<p><em><strong>&#x53C2;&#x8003;&#x4EE3;&#x7801;day13/flags.py</strong></em></p>
<ol>
<li>
<p>&#x4F7F;&#x7528;&#x51FD;&#x6570;&#xFF1A;re&#x6A21;&#x5757;&#x8C03;&#x7528;&#x7684;&#x5339;&#x914D;&#x51FD;&#x6570;&#x3002;&#x5982;&#xFF1A;re.compile,re.findall,re.search....</p>
</li>
<li>
<p>&#x4F5C;&#x7528;&#xFF1A;&#x6269;&#x5C55;&#x4E30;&#x5BCC;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5339;&#x914D;&#x529F;&#x80FD;</p>
</li>
<li>
<p>&#x5E38;&#x7528;flag</p>
</li>
</ol>
<blockquote>
<p>A == ASCII  &#x5143;&#x5B57;&#x7B26;&#x53EA;&#x80FD;&#x5339;&#x914D;ascii&#x7801;</p>
</blockquote>
<blockquote>
<p>I == IGNORECASE  &#x5339;&#x914D;&#x5FFD;&#x7565;&#x5B57;&#x6BCD;&#x5927;&#x5C0F;&#x5199;</p>
</blockquote>
<blockquote>
<p>S == DOTALL  &#x4F7F; . &#x53EF;&#x4EE5;&#x5339;&#x914D;&#x6362;&#x884C;</p>
</blockquote>
<blockquote>
<p>M == MULTILINE  &#x4F7F; ^  $&#x53EF;&#x4EE5;&#x5339;&#x914D;&#x6BCF;&#x4E00;&#x884C;&#x7684;&#x5F00;&#x5934;&#x7ED3;&#x5C3E;&#x4F4D;&#x7F6E;</p>
</blockquote>
<ol start="4">
<li>
<p>&#x4F7F;&#x7528;&#x591A;&#x4E2A;flag</p>
<p>&#x65B9;&#x6CD5;&#xFF1A;&#x4F7F;&#x7528;&#x6309;&#x4F4D;&#x6216;&#x8FDE;&#x63A5;<br>
e.g. &#xFF1A;  flags = re.I | re.A</p>
</li>
</ol>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>